# -*- coding: utf-8 -*-

# -------------------------------
# Author    : linlingwei
# Email     : 951035650@qq.com
# File Name : uninstall.py
# Date      : 2018/8/25
# Version   : 1.0.1
# -------------------------------

import os
import sys
import getpass

try:
    import maya.mel
    import maya.cmds
    isMaya = True
except ImportError:
    isMaya = False
def uninstall_modules():
    user_name = getpass.getuser()
    # C:\Users\Admin\Documents\maya\modules
    modules_path = os.path.join("C:\Users", user_name, "Documents\maya\modules")
    if not os.path.exists(modules_path):
        return
    modules_file = "lhotkey.mod"
    modules_file_path = os.path.join(modules_path, modules_file)
    if os.path.exists(modules_file_path):
        os.remove(modules_file_path)
        
    return

def uninstall_lhotkey_settings():
    import maya.cmds as mc
    ver = mc.about(version=True)
    
    if int(ver) > 2015:
        hotkeySetName = 'hotkeySet_lc'
        mc.hotkeySet(hotkeySetName, edit=True, delete=True)
        mc.hotkeySet("Maya_Default", edit=True, current=True)

    return


def uninstall():

    
    uninstall_modules()
    uninstall_lhotkey_settings()
    
    srcPath = os.path.join(os.path.dirname(__file__))
    srcPath = os.path.normpath(srcPath)
    sys.path.remove(srcPath)

    return
if isMaya:
    uninstall()
    print "uninstall lhotkey success."

if __name__ == '__main__':
    pass